package com.qihoo.finance.backup.app.configuration;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;

public class DataSourceConfiguration {

    private Environment environment;

    public DataSourceConfiguration(Environment environment) {
        this.environment = environment;
    }

    @Primary
    @Bean(name = "dataSource")
    @ConfigurationProperties(prefix = "crp.default")
    public DruidDataSource crpDataSource() {
        return DruidDataSourceBuilder.create().build(environment, "crp.default.");
    }
}
